<%@page import="search.transcoord.TransCoordLoader"%>
<%@page import="search.local.LocalItem"%>
<%@page import="java.util.ArrayList"%>
<%@page import="search.local.LocalLoader"%>
<%@page import="java.util.Calendar"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%
	String start = request.getParameter("start");
	String end = request.getParameter("end");
	String time = request.getParameter("time");
	String start_location = request.getParameter("start_location");
	String end_location = request.getParameter("end_location");

	if (start == null || start.equals("")) {
		start_location = new String(start_location.getBytes("ISO-8859-1"), "UTF-8");
		LocalLoader loader = new LocalLoader();
		ArrayList<LocalItem> list = loader.getLocalList(start_location);
		if (list != null) {
			if (!start_location.equals("")) {
				if (list.size() < 1) {
					out.print("<script type='text/javascript'>alert('검색된 출발지 정보가 없습니다.');history.back();</script>");
				} else {
					LocalItem item = list.get(0);
					TransCoordLoader tloader = new TransCoordLoader();
					start = tloader.getTransCoord(item.getMapx(), item.getMapy());
				}
			}
		}
	}
	
	if (end == null || end.equals("")) {
		end_location = new String(end_location.getBytes("ISO-8859-1"), "UTF-8");
		LocalLoader loader = new LocalLoader();
		ArrayList<LocalItem> list = loader.getLocalList(end_location);
		if (list != null) {
			if (!end_location.equals("")) {
				if (list.size() < 1) {
					out.print("<script type='text/javascript'>alert('검색된 도착지 정보가 없습니다.');history.back();</script>");
				} else {
					LocalItem item = list.get(0);
					TransCoordLoader tloader = new TransCoordLoader();
					end = tloader.getTransCoord(item.getMapx(), item.getMapy());
				}
			}
		}
	}
	
	if (start == null || start.equals("")) {
		out.print("<script>alert('출발지 입력이 필요합니다.');location.replace('index.jsp');</script>");
	}
	
	if (end == null || end.equals("")) {
		out.print("<script>alert('도착지 입력이 필요합니다.');location.replace('index.jsp');</script>");
	}
	
	if (time == null || time.equals("")) {
		Calendar cal = Calendar.getInstance();
		time = cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE);
	}
	
	int hh = Integer.parseInt(time.substring(0, 2));
	int mm = Integer.parseInt(time.substring(3, 5));
	
	if (start != null && !start.equals("") && end != null && !end.equals("")) {
		start = new String(start.getBytes("ISO-8859-1"), "UTF-8");
		end = new String(end.getBytes("ISO-8859-1"), "UTF-8");
	}
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

<!-- 모바일 웹 페이지 설정 -->
<link rel="shortcut icon" href="assets/ico/favicon.png" />
<link rel="apple-touch-icon-precomposed"
	href="assets/ico/apple-touch-icon-57-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="72x72"
	href="assets/ico/apple-touch-icon-72-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="114x114"
	href="assets/ico/apple-touch-icon-114-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="144x144"
	href="assets/ico/apple-touch-icon-144-precomposed.png" />

<!-- bootstrap -->
<link rel="stylesheet" type="text/css"
	href="assets/css/bootstrap.min.css" />
<!-- 나눔고딕 웹 폰트 적용 -->
<link rel="stylesheet" type="text/css" href="assets/css/nanumfont.css" />
<link rel="stylesheet" type="text/css"
	href="assets/font-awesome/css/font-awesome-ie7.css" />
<link rel="stylesheet" type="text/css"
	href="assets/font-awesome/css/font-awesome-ie7.min.css" />
<link rel="stylesheet" type="text/css"
	href="assets/font-awesome/css/font-awesome.css" />
<link rel="stylesheet" type="text/css"
	href="assets/font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css"
	href="assets/font-awesome-4.0.3/css/font-awesome.css" />
<link rel="stylesheet" type="text/css"
	href="assets/font-awesome-4.0.3/css/font-awesome.min.css" />

<!-- 반응형 웹을 지원하지 않을 경우 -->
<!-- <link rel="stylesheet" href="assets/css/non-
		responsive.css" /> -->

<!-- IE8 이하 버전 지원 -->
<!--[if lt IE 9]>
		<script type="text/javascript" src="assets/js/html5shiv.js"></
		script>
		<script type="text/javascript" src="assets/js/
		respond.min.js"></script>
		<![endif]-->
<!-- IE10 반응형 웹 버그 보완 -->
<!--[if gt IE 9]>
		<link rel="stylesheet" type="text/css" href="assets/css/
		ie10.css" />
		<script type="text/javascript" src="assets/js/ie10.js"></
		script>
		<![endif]-->

<title>select_result</title>

<style type="text/css">
body {
	padding-top: 50px;
}

nav.navbar {
	line-height: 50px;
}

.navbar span {
	color: #FFFFFF;
	font-size: 16px;
}

.nav_btns {
	width: 50px;
}

.list-case {
	background-color: #F8F8F8;
}

.fa-position {
	float: right;
	margin-top: 10px;
	margin-right: 5px;
}

.list-btn1 {
	float: right;
	margin-right: 5px;
}

.list-btn2 {
	float: right;
	margin-right: 5px;
}

.nav {
	position: absolute;
	bottom: 10px;
	width: 90%;
}

ul {
	padding: 0;
}

li {
	display: inline-block;
	list-style-type: none;
	float: right;
	margin-left: 5px;
}

.nav {
	position: absolute;
	bottom: 10px;
	width: 90%;
}

.nav-btn {
	color: #FFF;
	background: #428BCA;
	border-radius: 50%;
	border: 2px solid #FFF;
	font: 20px "Helvatica";
	display: inline-block;
	text-decoration: none;
	width: 40px;
	line-height: 40px;
	text-align: center;
	opacity: 0.5;
}

.panel>.panel-heading>.panel-title>a {
	text-decoration: none;
}
</style>
</head>

<body onload="calcRoute();">
	<input type="hidden" id="start" value="<%=start%>">
	<input type="hidden" id="end" value="<%=end%>">
	<input type="hidden" id="hh" value="<%=hh%>">
	<input type="hidden" id="mm" value="<%=mm%>">

	<!-- 상단 해더 바 -->
			<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
				<div class="container text-center">
					<div class="pull-left">
						<button class="btn btn-info nav_btns" onclick="history.back();">
							<i class="icon-arrow-left"></i>
						</button>
					</div>
					<span>검색결과</span>
				</div>
			</nav>
	<!-- 상단 해더 끝 -->

	<div id="test" class="panel-group">
	</div>
	
	<script src="assets/js/jquery.js"></script>
	<script src="assets/js/bootstrap.min.js"></script>	
	<script	src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
	<script src="assets/js/googlemap.js"></script>
	
</body>
</html>

